<?php if (!defined('THINK_PATH')) exit();?>
<script src="__PUBLIC__/plugins/uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/plugins/uploadify/uploadify.css">
<style type="text/css">
body {
	font: 13px Arial, Helvetica, Sans-serif;
}
</style>
	<form>
		<div id="queue"></div>
		<input id="file_upload" name="file_upload" type="file" multiple="true">
	</form>
	<div id="form01">
	</div>
	<script type="text/javascript">
		<?php $timestamp = time();?>
		
		function UploadifyUpload(formId,inputName){
		
			$('#file_upload').uploadify({
				'formData'     : {
					'timestamp' : '<?php echo $timestamp;?>',
					'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
				},
				'swf'      : '__PUBLIC__/plugins/uploadify/uploadify.swf',
				'uploader' : '<?php echo U("Api/uploadify");?>',
				'onUploadComplete' : function(file) {
					//alert('The file ' + file.name + ' finished processing.');
				},
				'onUploadSuccess' : function(file, data, response) { alert(data)
					var data = eval('(' + data + ')')
					if(data.status){
						var files = data.info;
						var html = '';
						//console.log(files);
						$.each(files,function(i,j){
							html+='<p class="imglist"> <input type="text" name="'+inputName+'[]" value="'+j.savepath+j.savename+'" readonly><a href="javascript:removeImg( this );" class="removeImg" >x</a></p>';
						})
						$("#"+formId+"").append(html);
						
					}else{
						alert(data.info);
					}
				}

			});
		
		}
		$(function() {
			UploadifyUpload('form01','upload');
			$(document).on('click','.removeImg',function(){
				removeImg($(this));
			})
			
		});
		function removeImg(_this){
			var a =_this.parent('p').html('');
			//alert(a)
		}
				
	</script>